//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <iostream>
#include <fstream>

#include "ListSmile.h"
#include "ListAncestorMol.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char **argv) {

  String* namefileAllSmiles   = NULL;
  String* namefileAllAncestor = NULL;
  String* namefileOutAncestor = NULL;

  if (argc < 4) {
    cout << "Error. Please enter all arguments to execute correctly!" << endl;
    cout << "./OrderAncestorFile <Name Ancestor File> <Name Smile File> <Name Output Files>" << endl;
    return 0;
  }
  else {
    namefileAllAncestor = new String(argv[1]);
    namefileAllSmiles   = new String(argv[2]);
    namefileOutAncestor = new String(argv[3]);
  }

  cout << "Read Input..." << endl;
  ListAncestorMol* listAncestorMol = new ListAncestorMol(namefileAllAncestor, namefileAllSmiles);
  cout << "Load Data..." << endl;
  listAncestorMol->LoadDataFiles();
  cout << "Order List..." << endl;
  listAncestorMol->OrderListByAncestorCenteredIterative();
  listAncestorMol->FilenameAncestor(namefileOutAncestor);
  cout << "Preparering the Output..." << endl;
  listAncestorMol->WriteAncestorFile();
  
  if (listAncestorMol)     delete listAncestorMol;
  
  if (namefileAllSmiles)   delete namefileAllSmiles;
  if (namefileAllAncestor) delete namefileAllAncestor;
  if (namefileOutAncestor) delete namefileOutAncestor;

  return 1;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//


